﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Services;
using Framework.UnitOfWork;
using Domain.Module.Entities;
using Framework.Infrastructure;
using Domain.Module.Roles;

namespace Application.AppServices.MBlogManagement
{
    class MBlogManagementService : ApplicationService, IMBlogManagementService
    {
        #region Construct
        public MBlogManagementService(IUnitOfWork unitOfWork) : base(unitOfWork)
        {

        }
        #endregion

        #region IMBlogManagementService Members

        public void PublishMBlog(Guid publisherID, Infrastructure.DataObject.MBlogObject mblogObject)
        {
            var userRepository = GetRepository<User>();
            var user = userRepository.GetByKey(publisherID);
            if (user != null)
            {
                var mblogPublisher = user.ActAs<IMblogPublisher>();
                mblogPublisher.PublishMblog(mblogObject);
            }
            UnitOfWork.Commit();
        }

        #endregion
    }
}
